<template>
  <div class="card-type" v-if="true">
    <div class="card-type-inside">
      <div class="header">
        <div class="left item">
          <img alt="左侧" src="@/components/assets/images/design/1-12.webp" />
        </div>
        <div class="middle item">请选择查询时间</div>
        <div class="right item">
          <img alt="右侧" src="@/components/assets/images/design/1-12.webp" />
        </div>
      </div>
      <el-row class="patient-number-area">
        <div class="One">
          <div class="title">开始时间</div>
          <van-datetime-picker
            v-model="startDate"
            type="date"
            :min-date="minDate"
            :max-date="maxDate"
            class="custom-datetime-picker"
            item-height="100px"
            visible-item-count="2"
            :show-toolbar="false"
          />
        </div>
        <div class="Two">
          <div class="title">结束时间</div>
          <van-datetime-picker
            v-model="endDate"
            type="date"
            :min-date="minDate"
            :max-date="maxDate"
            class="custom-datetime-picker"
            item-height="100px"
            visible-item-count="2"
            :show-toolbar="false"
          />
        </div>
        <div class="btnBox" @click="sureBtn">确定</div>
      </el-row>
    </div>
  </div>
</template>

<script>
import { AndroidToWeb, buildParentApi } from "@/utils/designer/util";
import { translateTime } from "@/utils/common";
let buildParent = buildParentApi();
export default {
  name: "QueryTime",

  componentName: "QueryTime",

  components: {},
  
  props:{
    formPage: {
      type: String,
      default: ''
    }
  },

  data() {
    return {
      minDate: new Date(2020, 0, 1),
      maxDate: new Date(2025, 10, 1),
      startDate: new Date(2021, 0, 17),
      endDate: new Date(2021, 0, 17),
    };
  },

  computed: {
    patientInfo() {
      return this.$store.getters["DRCbiz/getPatientInfo"];
    },
  },

  mounted() {},

  methods: {
    sureBtn() {

      const userId = this.$route.params.id;
      console.log(userId); // 输出: 123
      console.log(this.startDate, this.endDate);
      console.log(translateTime(this.startDate));
      if(this.formPage === 'query-paid-details'){
        this.$emit('queryPaidDetailsSure')
      }

      let params = {
        Request: {
          deviceIp: "",
          flowId: "",
          timestamp: "",
          terminalNo: "",
          method: "",
          patientId: "",
          startDate: "",
          endDate: "",
        },
      };
      let paramsInfo = this.$x2js.js2xml(params);
      switch (userId) {
        case "1": // PrintInvoice 收费发票打印  --门诊缴费   缺医保额度之类
          buildParent.executeParentMethod("axiosRep", paramsInfo, "PrintInvoice");
          break;
        case "2": // QueryRegisterRecord 挂号/预约记录查询  -挂号补打  实时会查一些，数据不全
          buildParent.executeParentMethod("axiosRep", paramsInfo, "QueryRegisterRecord");
          break;
        case "3":  // TakeAccount 预约取号      --预约取号   实时会查一些，数据不全
          buildParent.executeParentMethod("axiosRep", paramsInfo, "TakeAccount");
          break;
        case "4": // ZYQueryAddBalanceRecord --住院 住院预缴金充值记录查询    金额
          buildParent.executeParentMethod("axiosRep", paramsInfo, "ZYQueryAddBalanceRecord");
          break;
      }
    },
    handleFocusInput() {
      console.log("失焦");
      const self = this;
      setTimeout(() => {
        self.$refs.inputField?.focus();
      }, 100);
    },
  },
};
</script>

<style scoped lang="scss">
@import "./assets/style";
</style>